#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H

#include "animal.h"
#include "predator.h"
#include "prey.h"
#include "animalwrapper.h"

class Environment {
	public:
		Environment();
		~Environment();

		void clearWrapperLists();
		void deleteAllAgents();

		// Adds a new predator to the environment, positioned in (x,y)
		void addPredator(Predator * pred, int x, int y);
		// Adds a new prey to the environment, positioned in (x,y)
		void addPrey(Prey * prey, int x, int y);
		// Function used by prey to observe the environment
		int isPredatorNearby( Prey * prey );
		// Resets all agents to their starting position
		void resetAgentsPositions();
		// Runs a simulation, returns how many turns simulated
		int startSimulation();
		// Sets the printing mode for the simulation
		void setPrint( bool printMode );
		// Updates an agent position given its movement
		static void updatePosition(AnimalWrapper *animal, int direction);
		// Returns a value depending on how the two animals are positioned
		static int checkNearAnimals( AnimalWrapper * animal1, AnimalWrapper * animal2);


	private:
		// Add a new agent to the environment in the correct list, positioned in (x,y)
		void addAnimal(Animal* an, int x, int y, int type);

		// Pointers to predators/prey lists
		AnimalWrapper * predStart;
		AnimalWrapper * preyStart;
		// Map dimensions
		static int mapSizeX;
		static int mapSizeY;

		bool print;
};

#endif /* ENVIRONMENT_H_ */
